Hệ thống bổ nhiệm bác sĩ trong PHP bằng mã nguồn

1 <?php
2                     
3                     
// if(isset($_POST['submit'])){
4                             $target_dir =
"/photo";
5                             $target_file = $target_dir . basename($_FILES[
"pic"]["name"]);
6                             $uploadOk =
1;
7                             $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
8                             
// Check if image file is a actual image or fake image
9
10                             $check = getimagesize($_FILES[
"pic"]["tmp_name"]);
11                             
if($check !== false) {
12                                 
// echo "File is an image - " . $check["mime"] . ".";
13                                 $uploadOk =
1;
14                             }
else {
15                                 echo
"File is not an image.";
16                                 $uploadOk =
0;
17                             }
18
19                             
// Check if file already exists
20                             
if (file_exists($target_file)) {
21                                 echo
"Sorry, file already exists.";
22                                 $uploadOk =
0;
23                             }
24                             
//aloow certain file formats
25                             
if($imageFileType != "jpg" && $imageFileType !="png" && $imageFileType !="jpeg" && $imageFileType !="gif"){
26                                 echo
"sorry, only jpg, jpeg, Png & gif files are allowed.";
27                                 $uploadok=
0;
28                             }
29                         
else{
30                             
if(move_uploaded_file($_FILES["pic"]["tmp_name"], $target_file)) {
31                                 include(
'../config.php');
32                                 $sql =
"INSERT INTO doctor (name,address,contact,email,expertise,userid,fee,password,pic)
33                                     VALUES ('"
. $_POST["name"] . "','" . $_POST["address"] . "','" . $_POST["contact"] . "','" . $_POST["email"] . "', '" . $_POST["expertise"] . "','" . $_POST["userid"] . "','" . $_POST["fee"] . "','" . $_POST["password"] . "','" . basename($_FILES["pic"]["name"]) ."' )";
34
35                                     
if ($conn->query($sql) === TRUE) {
36                                         echo
"<script>alert('New Doctor Has been Added Successfully!');</script>";
37                                     }
else {
38                                         echo
"<script>alert('There was an Error')<script>";
39                                     }
40
41                                     $conn->close();
42                             }
else {
43                                 echo
"<script>alert('sorry there was an error uploading your file.');</script>";
44                             }
45                             
46                             
47                         }
48                 
// }
49             ?>
50         <!-- validation and insertion End-->


Gõ tìm kiếm nhanh...